<template>
  <div>
    <!-- 最上面 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <el-table :data="rightsList" stripe border style="width: 100%">
        <el-table-column type="index" label="#" width="53"> </el-table-column>
        <el-table-column prop="authName" label="权限名称" width="344">
        </el-table-column>
        <el-table-column prop="path" label="路径" width="344">
        </el-table-column>
        <el-table-column prop="level" label="权限等级" width="344">
          <el-button type="primary" plain size="mini">{{
            rightslevel
          }}</el-button>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //权限列表
      rightsList: [],
      rightslevel: ""
    };
  },
  created() {
    //获取所有权限
    this.getRightsList();
  },
  methods: {
    //获取权限列表
    async getRightsList() {
      const { data: res } = await this.$http.get("rights/list");
      // console.log(res);
      if (res.meta.status !== 200) {
        return this.$message.error("获取权限列表失败");
      } else {
        this.rightsList = res.data;
        // 权限等级的内容判断
        if (this.rightsList.level == "1") {
          this.rightslevel = "一级";
        } else if (this.rightsList.level == "2") {
          this.rightslevel = "二级";
        } else {
          this.rightslevel = "没级";
        }
      }
    }
  }
};
</script>

<style lang="less"></style>
